package cz.muni.fi.pa165.travelagency.persistence;

import cz.muni.fi.pa165.travelagency.entities.Order;
import java.util.List;

/**
 * Interface for DAO of orders
 *
 * @author Marián Mozola
 */
public interface IOrderDAO {

    /**
     * Creates an order and save it to database
     *
     * @param order
     * @throws IllegalArgumentException if order is null
     * @throws IllegalStateException if id of order is incorrect
     * @throws IllegalStateException if date of creation is incorrect
     * @throws IllegalStateException if number of persons are lesser than 1
     * @throws IllegalStateException if price is null or lesser than zero
     */
    void createOrder(Order order);

    /**
     * Deletes an order from database
     *
     * @param order
     * @throws IllegalArgumentException if order is null
     * @throws IllegalStateException if id of the order is null or incorrect
     */
    void deleteOrder(Order order);

    /**
     * Finds and returns all orders from database
     *
     * @return all orders
     */
    List<Order> findAll();

    /**
     * Finds and returns all unpaid orders
     *
     * @return all unpaid orders
     */
    List<Order> findUnpaid();

    /**
     * Returns single order with given id
     *
     * @param id id of desired order
     * @throws IllegalArgumentException if order is null or negative number
     */
    Order getOrder(Long id);

    /**
     * Updates given order in to the memory
     *
     * @param order order to update
     * @throws IllegalArgumentException if order is null
     * @throws IllegalStateException if id of order is incorrect
     * @throws IllegalStateException if date of creation is incorrect
     * @throws IllegalStateException if number of persons are lesser than 1
     * @throws IllegalStateException if price is null or lesser than zero
     */
    void updateOrder(Order order);
}
